<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
      <button>获取信息</button>
</body>
</html>
<script src='./lib/jquery.min.js'></script>
<script>
     //修改$对象
    // let $$ = $.noConflict();
    $(()=>{
        $("button").click(()=>{
             //jquery中有两种方法发送ajax
             // 1 简写
            /*  $.get("/testajax",{"username":"abc","pwd":"123"},(data)=>{
                 console.log(data);
                 console.log(data.name);
             },"json")  */

             //$.post("/testajax",{"name":"test","age":18},(data)=>{console.log(data)})
             
             //2完整写法(推荐)
             //$.ajax();
             $.ajax({
                type:"get",
                url:  "/testajax",
                data:{
                    "name":"test",
                    "age":18 
                },
                dataType:"json", //把返回的数据转为json对象
                success(data){
                        console.log(data);
                }
             })
         })
      })
</script>